package com.sky.mapper;

import com.sky.entity.SetmealDish;
import com.sky.vo.DishItemVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDishMapper {

    //根据菜品表id查询关联的套餐id
    List<Long> checkSetmealByDishId(List<Long> ids);

    //根据套餐id新增关联的菜品
    void addSetmealDish(List<SetmealDish> setmealDishes);

    //根据套餐表id删除其联系的数据
    void delete(List<Long> ids);

    //根据套餐id查询关联的数据
    @Select("select * from setmeal_dish where setmeal_id=#{id}")
    List<SetmealDish> checkSetmealBySetmealId(Long id);

    //根据id查询套餐包含的菜品
    @Select("select sd.copies as copies,d.description as description,d.image as image,sd.name as name " +
            "from setmeal_dish sd left join dish d on sd.dish_id=d.id where sd.setmeal_id=#{id}")
    List<DishItemVO> dishBySetmealId(Long id);
}
